package org.test.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.test.common.Context;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 基本ActionSupport类
 * @author Zheng
 */
@Controller
@Scope("prototype")
public abstract class BaseActionSupport extends ActionSupport{

	private static final long serialVersionUID 	= -9029280936161757494L;
	
	public final static String ACTION_SUCCESS 	= SUCCESS;
	public final static String ACTION_ERROR 	= ERROR;
	public final static String ACTION_NONE 		= NONE;
	public final static String ACTION_LOGIN 	= LOGIN;
	public final static String ACTION_INPUT 	= INPUT;

	public HttpSession getHttpSession(){
		return Context.getSession();
	}
	
	public  String getParameter(String name) {
		return (null==Context.getRequest().getParameter(name))?null:Context.getRequest().getParameter(name);
	}
	
	public  Object getRequestAttribute(String name) {
		return getRequest().getAttribute(name);
	}

	public  Object getSessionAttribute(String name) {
		 return this.getHttpSession().getAttribute(name);
	}	
	
	public HttpServletRequest getRequest() {
		return Context.getRequest();
	}


	public HttpServletResponse getResponse() {
		return Context.getResponse();
	}
	

}
